let timer1 = null
let timer2 = null
export const debounce = (fn, delay) => { // 防抖
  return function () {
    if (timer1) {
      clearTimeout(timer1)
    }
    timer1 = setTimeout(() => {
      fn.apply(this, arguments)
      timer1 = null
    }, delay)
  }
}
export const throttle = function (fn, delay) { // 节流
  return function () {
    if (timer2) {
      return
    }
    timer2 = setTimeout(() => {
      fn.apply(this, arguments)
      // console.log(this)
      timer2 = null
    }, delay)
  }
}
